﻿package com.wandian.view.components.ui.bank
{
	import com.wandian.ApplicationFacade;
	import com.wandian.controller.CLZNoticeName;
	import com.wandian.data.GameData;
	import com.wandian.util.CLZTxtTip;
	import com.wandian.view.components.ui.AddBtn;
	
	import flash.display.Sprite;
	import flash.events.Event;
  

    public class DepositPanel extends Object
    {
        private var _mcPanel:Sprite;
        private var _global:GameData;
        private var _facade:ApplicationFacade;

        public function DepositPanel()
        {
            this._global = GameData.getInstance();
            this._facade = ApplicationFacade.getInstance();
            return;
        }

        public function setPanel(param1:Sprite) : void
        {
            this._mcPanel = param1;
            this._mcPanel["number_txt"].text = "";
            this._mcPanel["number_txt"].restrict = "0-9";
            Texas.I._mcGameView.stage.focus = this._mcPanel["number_txt"];
            this._mcPanel["goldName_txt"].text = GameData.tip["DEPOSIT_GLOD_NAME"] + ":";
            this._mcPanel["number_txt"].tabIndex = 1;
            AddBtn.addCurrentFunBtn(param1, this.commitHandler, GameData.tip["COMMIT"], 291, 330);
            this._mcPanel["number_txt"].addEventListener(Event.CHANGE, this.inputTextHandler);
            CLZTxtTip.addTip(this._mcPanel["number_txt"], GameData.tip["BANK_DEPOSIT_NUM_TIP"]);
            return;
        }

        private function inputTextHandler(event:Event) : void
        {
            var _loc_2:* = uint(this._mcPanel["number_txt"].text);
            if (_loc_2 >= this._global.userInfo.userVo.money)
            {
                this._mcPanel["number_txt"].text = this._global.userInfo.userVo.money + "";
            }
            return;
        }

        private function commitHandler() : void
        {
            var _loc_1:* = uint(this._mcPanel["number_txt"].text);
            if (_loc_1 > this._global.userInfo.userVo.money)
            {
                _loc_1 = this._global.userInfo.userVo.money;
            }
            if (_loc_1 <= 0)
            {
                CLZTxtTip.addTip(this._mcPanel["number_txt"], "<font color=\'#ff0000\'>" + GameData.tip["BANK_ENTER_NUM_NOT_0_TIP"] + "</font>");
                return;
            }
            this._mcPanel["number_txt"].text = "";
            CLZTxtTip.removeTip(this._mcPanel["number_txt"]);
            this._facade.sendNotification(CLZNoticeName.BANK_COMMIT_DEPOSIT_GOLD_REQ, _loc_1);
            return;
        }

    }
}
